﻿Imports System.IO

Public Class File
    Private _Path As String
    Private _Size As Integer

    Public Property Path As String
        Get
            Return _Path
        End Get
        Set(value As String)
            _Path = value
        End Set
    End Property

    Public Property Size As Integer
        Get
            Return _Size
        End Get
        Set(value As Integer)
            If IsNumeric(value) Then _Size = value
        End Set
    End Property

    Public Sub New(ByVal currentPath As String, ByVal fullPath As String)
        Dim relativePath As String = getRelativePath(IO.Path.GetFullPath(fullPath), currentPath)

        Dim sizeReader As FileInfo = My.Computer.FileSystem.GetFileInfo(fullPath)
        _Path = relativePath
        _Size = sizeReader.Length
    End Sub

    Private Function getRelativePath(ByVal fullPath As String, ByVal currentPath As String) As String
        Dim splittedPath() As String = Split(fullPath, currentPath & "\")
        Return splittedPath(1)
    End Function
End Class
